<?php
include_once 'controller/default.php';
include_once 'connection/connection_database.php';

class comment {
    function Delete($comment_id){
        $sql = "DELETE FROM comment WHERE comment_id={$comment_id["id"]}";
        return mysql_query($sql) or die(mysql_error());
    }
    
    function FillAll(){
        $sql = "SELECT * FROM comment c, cate_board_page cb WHERE c.page_id=cb.page_id and comment_status=0";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }
    
    function FillAllQuestion(){
        $sql = "SELECT * FROM comment c, question q WHERE c.question_id=q.question_id and comment_status=0";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }
    
    function FillAllAccecpt(){
        $sql = "SELECT * FROM comment c, cate_board_page cb WHERE c.page_id=cb.page_id and comment_status=1";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }
    
    function FillAllQuestionAccecpt(){
        $sql = "SELECT * FROM comment c, question q WHERE c.question_id=q.question_id and comment_status=1";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }
    
    function FillOne($comment){
        $sql = "SELECT * FROM comment c, cate_board_page cb WHERE c.page_id=cb.page_id and comment_id={$comment["id"]}";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }
    
    function FillOneQuestion($comment){
        $sql = "SELECT * FROM comment c, question q WHERE c.question_id=q.question_id and comment_id={$comment["id"]}";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }
    
    function Update($comment){
        $sql = "UPDATE comment SET comment_status=1 WHERE comment_id={$comment["id"]}";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }
    
    function UnAccept($comment){
        $sql = "UPDATE comment SET comment_status=0 WHERE comment_id={$comment["id"]}";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }
}

?>
